#include<graphics.h>
#include<conio.h>
#include<stdio.h>
#include<time.h>

#define Width 640
#define Height 480

void main(){
	initgraph(Width,Height);
	int x,y,radius;
	int vx = 1;
	int vy = 1;
	radius = 20	;
	x = rand()%(int)(Width - 4 * radius)+2*radius;
	y = rand()%(int)(Height - 4 * radius)+2*radius;
	//x = Width/2;
//	y = Height/2;

	BeginBatchDraw();	
	while(1){
		setcolor(BLACK);
		setfillcolor(BLACK);
		fillcircle(x,y,radius);
	//	vx = 10*rand();//% Width;
	//	vy = 10*rand(); //% Height;
		x += vx;
		y += vy;	 
		if(x <= radius || x > Width - radius){
			vx = -vx;
		}
		if(y <radius || y >Height -radius){
			vy = -vy;
		}
		setcolor(RED);
		setfillcolor(BROWN);
		fillcircle(x,y,radius);

		FlushBatchDraw();
		Sleep(3);							
}
		EndBatchDraw();	   

		_getch();
		closegraph();

}